package org.smileface.designpattern.factory.simplefactory;

/**
 * @description:
 * @author: chujian
 * @since: 2022-02-14 22:23
 **/
public class SimpleFactoryMain {

    public static void main(String[] args) {
        // 常规使用方式： 由使用者自行创建需要的实例
        IColor color = new GreenColor();
        System.out.println(color.getRgbValue());

        color = new RedColor();
        System.out.println(color.getRgbValue());

        // # 工厂方式1
        ColorFactory colorFactory = new ColorFactory();
        IColor iColor = colorFactory.createColor("green");
        System.out.println(iColor.getRgbValue());

        // # 工厂方式2
        IColor color2 = colorFactory.createColor2("org.smileface.designpattern.factory.simplefactory.RedColor");
        System.out.println(color2.getRgbValue());

        // # 工厂方式3
        IColor color3 = colorFactory.createColor3(RedColor.class);
        System.out.println(color3.getRgbValue());

    }

}
